# -*- coding:utf-8 -*-
#! python3
from facecat import *

#点击单元格的方法
#grid 表格
#row 行
#column 列
#cell 单元格
#firstTouch:是否第一次触摸 
#firstPoint:第一次触摸的坐标 
#secondTouch:是否第二次触摸 
#secondPoint:第二次触摸的坐标
#clicks 点击次数
def onClickGridCell(grid, row, column, cell, firstTouch, firstPoint, secondTouch, secondPoint, clicks):
	print(cell.value)

gPaint = FCPaint() #创建绘图对象
gPaint.onClickGridCell = onClickGridCell

#消息循环
def WndProc(hwnd,msg,wParam,lParam):
	return WndProcDefault(gPaint,hwnd,msg,wParam,lParam)

#初始化窗体
createMainWindow(gPaint, "facecat-py", WndProc)
current_file_path = os.path.abspath(__file__)
current_file_dir = os.path.dirname(current_file_path)
file0 = open(current_file_dir + "\\xml\\gridexample.xml", encoding="UTF-8")
xml = file0.read()
file0.close()
renderFaceCat(gPaint, xml)
grid = findViewByName("Grid", gPaint.views)
for i in range(0,100):
	row = FCGridRow()
	grid.rows.append(row)
	for j in range(0,3):
		cell = FCGridCell()
		row.cells.append(cell)
		if j == 0:
			checkBox = FCCheckBox()
			addViewToGridCell(checkBox, cell, grid)
		else:
			cell.value = "Cell"
invalidate(gPaint)
showWindow(gPaint)